Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
@turf/boolean-point-in-polygon
Advanced tools
@turf/boolean-point-in-polygon is a module from the Turf.js library that allows you to determine if a given point is inside a polygon. This is useful for geospatial analysis, such as determining if a location falls within a specific area or boundary.
Check if a point is inside a polygon
This feature allows you to check if a given point is inside a specified polygon. The code sample demonstrates creating a point and a polygon, and then using the booleanPointInPolygon function to determine if the point is inside the polygon.
const turf = require('@turf/turf');
const point = turf.point([2, 2]);
const polygon = turf.polygon([[
[0, 0],
[0, 5],
[5, 5],
[5, 0],
[0, 0]
]]);
const isInside = turf.booleanPointInPolygon(point, polygon);
console.log(isInside); // true
The 'point-in-polygon' package provides similar functionality to @turf/boolean-point-in-polygon by allowing you to check if a point is inside a polygon. However, it is a more lightweight and standalone package compared to the comprehensive Turf.js library.
The 'geolib' package offers a wide range of geospatial functions, including checking if a point is inside a polygon. It is more versatile and includes additional features like distance calculations, but it may be more complex to use for simple point-in-polygon checks compared to @turf/boolean-point-in-polygon.
Takes a Point and a Polygon or MultiPolygon and determines if the point resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.
Parameters
point
Coord input pointpolygon
Feature<(Polygon | MultiPolygon)> input polygon or multipolygonoptions
Object Optional parameters (optional, default {}
)
options.ignoreBoundary
boolean True if polygon boundary should be ignored when determining if the point is inside the polygon otherwise false. (optional, default false
)Examples
var pt = turf.point([-77, 44]);
var poly = turf.polygon([[
[-81, 41],
[-81, 47],
[-72, 47],
[-72, 41],
[-81, 41]
]]);
turf.booleanPointInPolygon(pt, poly);
//= true
Returns boolean true
if the Point is inside the Polygon; false
if the Point is not inside the Polygon
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Install this module individually:
$ npm install @turf/boolean-point-in-polygon
Or install the Turf module that includes it as a function:
$ npm install @turf/turf
6.5.0
@turf/points-with-polygon
Add MultiPoint support
(PR https://github.com/Turfjs/turf/pull/2137 - Author @twelch)@turf/dissolve
Complete rewrite of the dissolve module to resolve many bugs
(PR https://github.com/Turfjs/turf/pull/2110 - Author @rowanwins)
@turf/mask
Complete rewrite of the mask module to resolve many bugs
(PR https://github.com/Turfjs/turf/pull/2130 - Author @rowanwins)
@turf/boolean-valid
Add missing dependency to
(PR https://github.com/Turfjs/turf/pull/2094 - Author @rycgar)
@turf/boolean-overlap
Improve clarity
(PR https://github.com/Turfjs/turf/pull/2133 - Author @patrickbrett)FAQs
turf boolean-point-in-polygon module
The npm package @turf/boolean-point-in-polygon receives a total of 643,088 weekly downloads. As such, @turf/boolean-point-in-polygon popularity was classified as popular.
We found that @turf/boolean-point-in-polygon demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.